package com.whisperarts.financer.app;

import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.commands.ICommandService;

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

	private static final String PERSPECTIVE_ID = "com.whisperarts.financer.app.perspective"; //$NON-NLS-1$

    @Override
	public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        return new ApplicationWorkbenchWindowAdvisor(configurer);
    }

	@Override
	public String getInitialWindowPerspectiveId() {
		return PERSPECTIVE_ID;
	}
	
	@Override
	public void postStartup() {
		super.postStartup();
		
		//Disables NewEditor action
		//NOT SURE IF ITS CORRECT
		//See https://bugs.eclipse.org/bugs/show_bug.cgi?id=103045#c25
		ICommandService commandService = (ICommandService)
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);				      
		commandService.getCommand("org.eclipse.ui.window.newEditor").setHandler(null);
	}
}
